package com.cloudsigns.factorymanager2.produce.presenter;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.IProductOrderEditView;
import com.cloudsigns.factorymanager2.produce.model.IProductOrderEditModel;
import com.cloudsigns.factorymanager2.produce.model.ProductOrderEditModel;

public class ProductOrderEditPresenter {
    private IProductOrderEditView view;
    private IProductOrderEditModel model;
    private Handler handler = new Handler();

    public ProductOrderEditPresenter(IProductOrderEditView view) {
        this.view = view;
        this.model = new ProductOrderEditModel();
    }

    public void productOrderEdit() {
        model.getProductOrderEdit(view.getBeginDate(), view.getFinishDate(), view.getOrderId(), view.getProductId(), view.getWorkPartList(), new ProductOrderEditModel.OnProductOrderEditListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.getProductOrderEditSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(String desc) {
                view.getProductOrderEditFailed(desc);
                view.hideLoading();
            }
        });
    }
}
